home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / CMPLTPAS / TALLY.PAS < prev    next >
Pascal/Delphi Source File  |  1988-07-25  |  3KB  |  83 lines

  1. {--------------------------------------------------------------}
  2. {                           Tally                              }
  3. {                                                              }
  4. {  File size tally utility; works throughout directory trees   }
  5. {                                                              }
  6. {                             by Jeff Duntemann                }
  7. {                             Turbo Pascal V5.0                }
  8. {                             Last update 7/25/88              }
  9. {                                                              }
  10. {     From: COMPLETE TURBO PASCAL 5.0  by Jeff Duntemann       }
  11. {    Scott, Foresman & Co., Inc. 1988   ISBN 0-673-38355-5     }
  12. {--------------------------------------------------------------}
  13.  
  14. {$F+}          { To be safe, use FAR calls throughout... }
  15. PROGRAM Tally;
  16.  
  17. USES DOS,Searcher;  { Using SEARCHER requires Version 5.0! }
  18.  
  19. VAR
  20.   I          : Integer;
  21.   Total      : LongInt;
  22.   SearchSpec : String;
  23.   InitialDirectory : String;
  24.  
  25.  
  26. PROCEDURE Tallier(Foundit : SearchRec;InDirectory : String);
  27.  
  28. BEGIN
  29.   IF InDirectory = '\' THEN
  30.     Writeln(InDirectory,Foundit.Name)
  31.   ELSE
  32.     Writeln(InDirectory,'\',FoundIt.Name);
  33.   Total := Total + Foundit.Size;
  34. END;
  35.  
  36.  
  37. BEGIN
  38.   IF ParamCount = 0 THEN
  39.     BEGIN
  40.       Writeln('>>TALLY<<  V1.00  By Jeff Duntemann');
  41.       Writeln('           From the book, COMPLETE TURBO PASCAL 5.0');
  42.       Writeln('           Scott, Foresman & Co. 1988');
  43.       Writeln('           ISBN 0-673-38355-5');
  44.       Writeln;
  45.       Writeln('This program searches for all files matching a given ');
  46.       Writeln('filespec on the current disk device, in any subdirectory.');
  47.       Writeln('It displays their full pathnames, and keeps a total of ');
  48.       Writeln('the size that each occupies, so that you can determine');
  49.       Writeln('just how much space you have tied up in .BAK files,');
  50.       Writeln('throughout your entire disk volume.');
  51.       Writeln;
  52.       Writeln('CALLING SYNTAX:');
  53.       Writeln;
  54.       Writeln('TALLY <filespec>');
  55.       Writeln;
  56.       Writeln('For example, to find out how much space your screen capture');
  57.       Writeln('files (ending in .CAP) occupy, you would enter:');
  58.       Writeln;
  59.       Writeln('TALLY *.CAP');
  60.       Writeln;
  61.     END
  62.   ELSE
  63.     BEGIN
  64.       Total := 0;
  65.       Writeln;
  66.       SearchSpec := ParamStr(1);
  67.       { A "naked" filespec searches the entire volume: }
  68.       IF Pos('\',SearchSpec) = 0 THEN
  69.         InitialDirectory := '\'
  70.       ELSE
  71.         BEGIN
  72.           { This rigamarole separates the filespec from the path: }
  73.           I := Length(SearchSpec);
  74.           WHILE SearchSpec[I] <> '\' DO I := Pred(I);
  75.           InitialDirectory := Copy(SearchSpec,1,I-1);
  76.           Delete(SearchSpec,1,I);
  77.         END;
  78.       SearchAll(InitialDirectory,SearchSpec,0,Tallier);
  79.       Writeln('The files listed occupy ',Total,' bytes of disk space.');
  80.     END
  81. END.
  82.  
  83.